<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="fragments/head::head"/>
<link rel="stylesheet" th:href="@{/assets/css/colorbox.css}"/>
<style type="text/css">
</style>
<body style='overflow:visible ! important;'>
<div th:include="fragments/top::top"></div>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <div th:include="fragments/left::left" class="sidebar" id="sidebar"></div>
        <div class="main-content">
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="row">
                            <div class="col-xs-12">
                                <h3 class="header smaller lighter blue">预科学生信息列表</h3>
                                <div class="table-header">
                                    <form class="form-inline">
                                        <div class="form-group">
                                            <input type="hidden" id="headmasterNo" th:value="${session.user.oaid}"/>
                                            <label for="studentNo">学号：</label>
                                            <input type="text" id="studentNo" class="form-control input-sm"
                                                   style="width:100px;"/>
                                            <label for="sName">姓名/拼音：</label>
                                            <input type="text" id="sName" class="form-control input-sm"
                                                   style="width:100px;"/>
                                            <label for="sName">是/否分配老师</label>
                                            <select type="" class="form-control input-sm" id="isAllot"
                                                    style="width:60px;">
                                                <option value="0" selected="selected">请选择</option>
                                                <option value="1">已分配</option>
                                                <option value="2">未分配</option>
                                            </select>
                                            <label for="sName">是/否已转案</label>
                                            <select type="" class="form-control input-sm" id="isTransfer"
                                                    style="width:60px;">
                                                <option value="0" selected="selected">请选择</option>
                                                <option value="1">已转案</option>
                                                <option value="2">未转案</option>
                                            </select>
                                        </div>

                                        <div class="form-group">
                                        </div>
                                        <button type="button" id="query" class="btn btn-success ">查询</button>
                                        <button class="btn btn-warning">清空</button>
                                    </form>

                                </div>

                                <div class="tab-pane fade in active" id="transfer_content">
                                    <div class="form-group" style="height:29px">
                                        <label class="col-sm-3 control-label no-padding-right blue">转案备注：</label>
                                        <textarea class="col-sm-2" style="width: 300px;height: 200px" name="remark" id="remark"></textarea>
                                    </div>
                                </div>

                                <div class="table-responsive">
                                    <div id="alert" class="alert alert-success" style="display: none;" role="alert">
                                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                            <span aria-hidden="true">&times;</span>
                                        </button>
                                        <span id="alertText"></span>
                                    </div>
                                    <table id="sample-table-2" class="table table-striped table-bordered table-hover"
                                           style="white-space: nowrap;">
                                        <thead>
                                        <tr>
                                            <th>学号</th>
                                            <th>姓名</th>
                                            <th>拼音</th>
                                            <th>出生日期</th>
                                            <th>国家</th>
                                            <th>咨询顾问</th>
                                            <th>合同名称</th>
                                            <th>分支机构</th>
                                            <th>签约日期</th>
                                            <th>预科班主任姓名</th>
                                            <th>是否已转案</th>
                                            <th>转案备注</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>

        <div th:include="fragments/bottom::bottom"></div>
    </div>

    <a href="#" id="btn-scroll-up"
       class="btn-scroll-up btn btn-sm btn-inverse"> <i
            class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
</div>
<!-- /.main-container -->


<div th:include="fragments/js::js"></div>
<script th:src="@{/assets/js/jquery.validate.min.js}"></script>
<script th:src="@{/assets/js/jquery.validate.zh-CN.js}"></script>
<!-- page specific plugin scripts -->
<script th:src="@{/assets/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/assets/js/jquery.dataTables.bootstrap.js}"></script>
<script th:src="@{/assets/js/date-time/moment.min.js}"></script>
<script th:src="@{/assets/js/temp.js}" charset="UTF-8"></script>
<!--图片查看器-->
<script th:src="@{/assets/js/jquery.colorbox-min.js}"></script>
<script th:src="@{/layer/layer.js}"></script>
<script th:src="@{/business/preStudentInfo/list.js}" charset="UTF-8"></script>
<!--<script th:src="@{/assets/js/date-time/moment.min.js}"></script>-->
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/

    var oTable1;
    jQuery(function ($) {
        oTable1 = $('#sample-table-2').dataTable({
            "scrollX": true,
//            "sScrollX": "100%",
            "scrollCollapse": true,
            "bFilter": false,//是否使用搜索
            "bProcessing": true,
            "bDeferRender": true,//
            "sPaginationType": "bs_normal",//分页样式
            "bRetrieve": true,//是否调用后台
            "bServerSide": true,//是否以后台分页
//            "fnRowCallback": function (nRow, aData, iDisplayIndex) {
//                if(aData.content != "" || aData.content != null){
//                    if (aData.content.length > 6) {
//                        $('td:eq(12)', nRow).html( '<a class="blue" href="javascript:void(0);" id="tip_content" onclick="toTipContent(\''+aData.content+'\')">'+aData.content.substr(0, 6)+"…"+'</a>');
//                    }
//                }
//
//            },
            "sAjaxSource": "/preStudentInfo/list",//请求路径
            "fnServerData": function (sSource, aoData, fnCallback) {
                aoData.push(
                    {"name": "headmasterNo", "value": $("#headmasterNo").val() == "" ? null : $("#headmasterNo").val()},
                    {"name": "studentNo", "value": $("#studentNo").val() == "" ? null : $("#studentNo").val()},
                    {"name": 'studentName', "value": $("#sName").val() == "" ? null : $.trim($("#sName").val())},
                    {
                        name: 'isAllot',
                        value: $("#isAllot").find("option:selected").val() == "" ? null : $("#isAllot").find("option:selected").val()
                    },
                    {
                        name: 'isTransfer',
                        value: $("#isTransfer").find("option:selected").val() == "" ? null : $("#isTransfer").find("option:selected").val()
                    }
                )
                $.ajax({
                    "dataType": 'json',
                    "type": "GET",
                    "url": sSource,
                    "data": aoData,
                    "success": fnCallback
                });
            },
            "aaSorting": [[0, "desc"]],
            "bSort": true,
            "aoColumns": [
                {"sClass": "center", "bSortable": false, "mData": "studentNo"},
                {"sClass": "center", "bSortable": false, "mData": "studentName"},
                {"sClass": "center", "bSortable": false, "mData": "pinyin"},
                {
                    "sClass": "center", "bSortable": false, "mData":
                    function (data) {
                        return getTimeString_day(new Date(data.birthday))
                    }
                },
                {"sClass": "center", "bSortable": false, "mData": "nationName",},
                {"sClass": "center", "bSortable": false, "mData": "salesConsultant",},
                {"sClass": "center", "bSortable": false, "mData": "contractNo",},
                {"sClass": "center", "bSortable": false, "mData": "branchName",},
                {
                    "sClass": "center", "bSortable": false, "mData":
                    function (data) {
                        return getTimeString_day(new Date(data.signDate))
                    }
                },
                {"sClass": "center", "bSortable": false, "mData": "headmasterName",},
                {
                    "sClass": "center", "bSortable": false, "mData":
                    function (data) {
                        if (data.isTransfer == 1) {
                            return "已转案"
                        } else {
                            return "未转案"
                        }
                    }
                },
                {
                    "sClass": "left", "bSortable": false,  "mData": function (data) {
                    if(data.content==null|| data.content==""){
                        return ""
                    }
                    if (data.content.length > 6) {
                        return '<a href="javascript:void(0);" id="'+data.id+'" onclick="toTipContent(' + data.id + ',\'' +  data.content.replace(/\r\n/mg,'  ') + '\')" >'+data.content.substring(0,6)+"..."+'</a>';
                    }else{
                        return data.content;
                    }
                    return data.content;
                }
                },

                {
                    "sClass": "center", "bSortable": false, "mData":
                    function (data) {
                        var allocation = "";
                        allocation = '<a href="javascript:void(0);" onclick="toAllocation(\'' + data.studentNo + '\')" >分配</a>';
                        var tranfer = "";
                        if (data.isTransfer != 1) {
                                tranfer = '&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="toTransfer(\'' + data.studentNo + '\')" >转案</a>';

                        }
                        return allocation + tranfer;

                    }
                },


            ],
            "oLanguage": {
                "sLengthMenu": "每页 _MENU_条 ",
                "sZeroRecords": "对不起，查询不到任何相关数据",
                "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录 ",
                "sInfoEmpty": "显示 0 到 0 条，共 0 条记录",
                "sInfoFiltered": "数据表中共为 _MAX_ 条记录)",
                "sProcessing": "正在加载中...",
                "sSearch": "搜索",
                "sUrl": "", //多语言配置文件，可将oLanguage的设置放在一个txt文件中，例：Javascript/datatable/dtCH.txt
                "oPaginate": {
                    "sFirst": "第一页",
                    "sPrevious": " 上一页 ",
                    "sNext": " 下一页 ",
                    "sLast": " 最后一页 "
                }
            }
            //多语言配置

        });


        $("#query").click(function () {
            oTable1.fnDraw();
        })

    })

    $("#transfer_content").hide();

    function getTimeString_day(date) {
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m >= 10 ? m : '0' + m;
        var d = date.getDate();
        d = d >= 10 ? d : '0' + d;
        return y + '-' + m + '-' + d;
    }

    function toTipContent(id,content){
        layer.tips(content, $("#"+id), {
            tips: [1, '#3595CC'],
            time: 3000
        });
    }

    /*]]>*/
</script>
</body>
</html>
